"""
项目启动文件
"""
from flask import Flask, request
from app import create_app
from flask import jsonify

# 创建app对象
app = create_app('dev')   # ['dev', 'pro', 'test']

@app.route('/')
def index():
    # 需求：返回所有类视图的路由信息json字符串
    # app.url_map.iter_rules() ==>返回可迭代对象
    # 构建路由字典：{"路由路径": "视图函数名称"}
    # 字典推导式
    rule_dict = {rule.rule: rule.endpoint for rule in app.url_map.iter_rules()}
    return jsonify(rule_dict)
